home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / CIncludes / NumberFormatting.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  4.4 KB  |  196 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        NumberFormatting.h
  3.  
  4.      Contains:    Utilites for formatting numbers
  5.  
  6.      Version:    Technology:    
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1996-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __NUMBERFORMATTING__
  18. #define __NUMBERFORMATTING__
  19.  
  20. #ifndef __CONDITIONALMACROS__
  21. #include <ConditionalMacros.h>
  22. #endif
  23. #ifndef __MACTYPES__
  24. #include <MacTypes.h>
  25. #endif
  26. #ifndef __INTLRESOURCES__
  27. #include <IntlResources.h>
  28. #endif
  29.  
  30.  
  31.  
  32.  
  33. #if PRAGMA_ONCE
  34. #pragma once
  35. #endif
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT
  42. #pragma import on
  43. #endif
  44.  
  45. #if PRAGMA_STRUCT_ALIGN
  46.     #pragma options align=mac68k
  47. #elif PRAGMA_STRUCT_PACKPUSH
  48.     #pragma pack(push, 2)
  49. #elif PRAGMA_STRUCT_PACK
  50.     #pragma pack(2)
  51. #endif
  52.  
  53. /*
  54.  
  55.     Here are the current System 7 routine names and the translations to the older forms.
  56.     Please use the newer forms in all new code and migrate the older names out of existing
  57.     code as maintainance permits.
  58.     
  59.     New Name                    Old Name(s)
  60.     
  61.     ExtendedToString            FormatX2Str
  62.     FormatRecToString            Format2Str
  63.     NumToString                
  64.     StringToExtended            FormatStr2X
  65.     StringToFormatRec            Str2Format
  66.     StringToNum                
  67.  
  68. */
  69.  
  70. struct NumFormatString {
  71.     UInt8                             fLength;
  72.     UInt8                             fVersion;
  73.     char                             data[254];                    /* private data */
  74. };
  75. typedef struct NumFormatString            NumFormatString;
  76. typedef NumFormatString                 NumFormatStringRec;
  77.  
  78. typedef short                             FormatStatus;
  79.  
  80. enum {
  81.     fVNumber                    = 0                                /* first version of NumFormatString */
  82. };
  83.  
  84. typedef SInt8                             FormatClass;
  85.  
  86. enum {
  87.     fPositive                    = 0,
  88.     fNegative                    = 1,
  89.     fZero                        = 2
  90. };
  91.  
  92. typedef SInt8                             FormatResultType;
  93.  
  94. enum {
  95.     fFormatOK                    = 0,
  96.     fBestGuess                    = 1,
  97.     fOutOfSynch                    = 2,
  98.     fSpuriousChars                = 3,
  99.     fMissingDelimiter            = 4,
  100.     fExtraDecimal                = 5,
  101.     fMissingLiteral                = 6,
  102.     fExtraExp                    = 7,
  103.     fFormatOverflow                = 8,
  104.     fFormStrIsNAN                = 9,
  105.     fBadPartsTable                = 10,
  106.     fExtraPercent                = 11,
  107.     fExtraSeparator                = 12,
  108.     fEmptyFormatString            = 13
  109. };
  110.  
  111.  
  112. struct FVector {
  113.     short                             start;
  114.     short                             length;
  115. };
  116. typedef struct FVector                    FVector;
  117. /* index by [fPositive..fZero] */
  118.  
  119. typedef FVector                         TripleInt[3];
  120. #if CGLUESUPPORTED
  121. EXTERN_API_C( void )
  122. stringtonum                        (const char *            theString,
  123.                                  long *                    theNum);
  124.  
  125. EXTERN_API_C( void )
  126. numtostring                        (long                     theNum,
  127.                                  char *                    theString);
  128.  
  129. #endif  /* CGLUESUPPORTED */
  130.  
  131. EXTERN_API( void )
  132. StringToNum                        (ConstStr255Param         theString,
  133.                                  long *                    theNum);
  134.  
  135. EXTERN_API( void )
  136. NumToString                        (long                     theNum,
  137.                                  Str255                 theString);
  138.  
  139.  
  140. EXTERN_API( FormatStatus )
  141. ExtendedToString                (const extended80 *        x,
  142.                                  const NumFormatString * myCanonical,
  143.                                  const NumberParts *    partsTable,
  144.                                  Str255                 outString)                            FOURWORDINLINE(0x2F3C, 0x8210, 0xFFE8, 0xA8B5);
  145.  
  146. EXTERN_API( FormatStatus )
  147. StringToExtended                (ConstStr255Param         source,
  148.                                  const NumFormatString * myCanonical,
  149.                                  const NumberParts *    partsTable,
  150.                                  extended80 *            x)                                    FOURWORDINLINE(0x2F3C, 0x8210, 0xFFE6, 0xA8B5);
  151.  
  152. EXTERN_API( FormatStatus )
  153. StringToFormatRec                (ConstStr255Param         inString,
  154.                                  const NumberParts *    partsTable,
  155.                                  NumFormatString *        outString)                            FOURWORDINLINE(0x2F3C, 0x820C, 0xFFEC, 0xA8B5);
  156.  
  157. EXTERN_API( FormatStatus )
  158. FormatRecToString                (const NumFormatString * myCanonical,
  159.                                  const NumberParts *    partsTable,
  160.                                  Str255                 outString,
  161.                                  TripleInt                 positions)                            FOURWORDINLINE(0x2F3C, 0x8210, 0xFFEA, 0xA8B5);
  162.  
  163.  
  164. #if OLDROUTINENAMES
  165. #define FormatX2Str(x, myCanonical, partsTable, outString)  \
  166.          ExtendedToString( x, myCanonical, partsTable, outString)
  167. #define FormatStr2X(source, myCanonical, partsTable, x)  \
  168.          StringToExtended( source, myCanonical, partsTable, x)
  169. #define Str2Format(inString, partsTable, outString)  \
  170.          StringToFormatRec(inString, partsTable, outString)
  171. #define Format2Str(myCanonical, partsTable, outString, positions)  \
  172.          FormatRecToString(myCanonical, partsTable, outString, positions)
  173. #endif  /* OLDROUTINENAMES */
  174.  
  175.  
  176. #if PRAGMA_STRUCT_ALIGN
  177.     #pragma options align=reset
  178. #elif PRAGMA_STRUCT_PACKPUSH
  179.     #pragma pack(pop)
  180. #elif PRAGMA_STRUCT_PACK
  181.     #pragma pack()
  182. #endif
  183.  
  184. #ifdef PRAGMA_IMPORT_OFF
  185. #pragma import off
  186. #elif PRAGMA_IMPORT
  187. #pragma import reset
  188. #endif
  189.  
  190. #ifdef __cplusplus
  191. }
  192. #endif
  193.  
  194. #endif /* __NUMBERFORMATTING__ */
  195.  
  196.